package thread;

public class SyncDemo3 {
    public static void main(String[] args) {
        StringBuffer s1 = new StringBuffer();
        //StringBuilder stringBuilder = new StringBuilder();
        Thread t1 = new Thread(){
            public void run(){
                for (int i = 0; i < 1000; i++) {
                    s1.append("aaa");
                }
            }
        };

        Thread t2 = new Thread(){
            public void run(){
                for (int i = 0; i < 1000; i++) {
                    s1.append("bbb");
                }
            }
        };

        t1.start();
        t2.start();

        try {
            Thread.sleep(50);
        } catch (InterruptedException e) {}
        System.out.println(s1.length());

    }
}
